/**
 * VUEshop
 * ============================================================================
 * * 版权所有 2015-2027 深圳搜豹网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.vueshop.com.cn
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: soubao-java 2020-07-22 $
 */<template>
  <div>
    <div class="item-title">
      <router-link
        class="back"
        :to="{name:'guarantee_list',params:{currentPage:$route.params.currentPage}}"
        title="返回列表"
      >
        <i class="fa fa-arrow-circle-o-left"></i>
      </router-link>
      <div class="subject">
        <h3>消费者保障服务</h3>
        <h5>保证金日志</h5>
      </div>
    </div>
    <div style="margin-top:20px">
      <el-form :model="guarantee" label-width="160px">
        <el-form-item label="店铺名称：">{{guarantee.store_name}}</el-form-item>
        <el-form-item label="项目名称：">{{guarantee.grt_name}}</el-form-item>
        <el-form-item label="保证金余额：">{{guarantee.cost}}</el-form-item>
        <el-form-item label="状态：">{{guarantee.auditstate_desc}}</el-form-item>
      </el-form>
    </div>
    <div class="mDiv">
      <div class="ftitle">
        <h3>保证金日志列表</h3>
        <h5>(共 {{totalCount}} 条记录)</h5>
      </div>
      <a href @click.prevent="refresh()" class="refresh-date">
        <div title="刷新数据" class="pReload">
          <i class="fa fa-refresh"></i>
        </div>
      </a>
    </div>

    <div class="tablebox">
      <el-table :data="tableData" ref="multipleTable" style="width: 100%;">
        <el-table-column label="店铺名称" prop="store_name" width="200"></el-table-column>
        <el-table-column label="保障服务" prop="grt_name" width="150"></el-table-column>
        <el-table-column label="金额（元）" prop="price" width="150" :formatter="priceToFixed"></el-table-column>
        <el-table-column label="添加时间" prop="add_time_desc" width="200"></el-table-column>
        <el-table-column label="操作人" prop="admin_name" width="180"></el-table-column>
        <el-table-column label="描述" prop="desc" width="300"></el-table-column>
      </el-table>
      <el-pagination
        background
        class="paginationbox"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="totalCount"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
import { getGuarantee, getGuaranteeCostLogList } from "@/utils/api";
export default {
  data() {
    return {
      tableData: [],
      currentPage: this.$route.params.currentPage || 1,
      totalCount: 0,
      pageSize: 10,
      guarantee: {}
    };
  },
  created() {
    this.getGuarantee();
  },
  methods: {
    handleSizeChange(e) {
      this.pageSize = e;
      this.getPage();
    },
    handleCurrentChange(e) {
      this.currentPage = e;
      this.getPage();
    },
    getGuarantee() {
      var that = this;
      getGuarantee({
        id: this.$route.params.id
      }).then(function(res) {
        res.cost = res.cost.toFixed(2);
        that.guarantee = res;
        that.getPage();
      });
    },
    getPage() {
      var that = this;
      getGuaranteeCostLogList({
        store_id: this.guarantee.store_id,
        grt_id: this.guarantee.grt_id,
        page: this.currentPage,
        size: this.pageSize
      }).then(function(res) {
        that.tableData = res.records;
        that.totalCount = res.total;
      });
    },
    refresh() {
      this.getGuarantee();
      this.$message({
        type: "success",
        message: "刷新成功！"
      });
    },
    priceToFixed(row) {
      return parseFloat(row.price).toFixed(2);
    }
  }
};
</script>

<style scoped>
</style>
